// 大的数值变成亿，万

import { Pipe, PipeTransform } from '@angular/core';

// import { TranslatePipe } from '../translate'; // our translate service

@Pipe({ name: 'bigNum' })

export class BigNum implements PipeTransform {

  // constructor(private _translate: TranslatePipe) { }

  transform(value: number): string {



    let units = Math.ceil(value).toString();

    let ex: any;

    if (units.length <= 4) {

      ex = value;

    } else if (units.length > 4 && units.length <= 8) {

      ex = (value / 10000).toFixed(2) + '万';

    } else if (units.length > 8 && units.length <= 12) {

      ex = (value / 100000000).toFixed(2) + '亿';

    } else {

      ex = (value / 1000000000000).toFixed(2) + '万亿';

    }

    return ex;
  }
}
